<%@ page contentType="text/html;charset=utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang='en'>
    <head>
        <meta charset='UTF-8'>
        <title>List Page</title>
        <base href="${pageContext.request.scheme}://${pageContext.request.serverName}:${pageContext.request.serverPort}${pageContext.request.contextPath}/"/>
    </head>
    <body>
        <h3>欢迎，在线人数${onlinecount}人</h3>
        <a href="${pageContext.request.contextPath}/user/exit">退出系统</a>

        <script type='text/javascript'>
            function del(deptno){
                var ok=window.confirm('亲，请确认删除');
                if(ok){
                    document.location.href='${pageContext.request.contextPath}/dept/delete?deptno='+deptno;
                }
            }
        </script>
        <h1 align='center'>部门列表</h1>
        <hr/>
        <table border='1px' align='center' width='50%'>
            <tr>
                <th>序号</th>
                <th>部门编号</th>
                <th>部门名称</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${deptList}" varStatus="deptStatus" var="dept">
                <tr>
                    <td>${deptStatus.count}</td>
                    <td>${dept.deptno}</td>
                    <td>${dept.dname}</td>
                    <td>
                        <a href='${pageContext.request.contextPath}/dept/detail?f=modify&deptno=${dept.deptno}'>修改</a>
                        <a href='javascript:void(0)' onclick='del(${dept.deptno})'>删除</a>
                        <a href='${pageContext.request.contextPath}/dept/detail?f=detail&deptno=${dept.deptno}'>详情</a>
                    </td>
                </tr>
            </c:forEach>
        </table>
        <hr/>
        <a href='add.jsp'>新增部门</a>
    </body>
</html>